const BASE_CINEMA_CODE = 15076020

const post = (url, params = {}, code) => {
	let cinemaCode = uni.getStorageSync('cinemaCode') || BASE_CINEMA_CODE
	if (code) cinemaCode = code
	const baseUrl = `https://pandl.xyz/JavaWeb5/api`
	return new Promise((resolve, reject) => {
		uni.request({
			header: {
				cinemaCode
			},
			url: baseUrl + url,
			method: "POST",
			data: params,
			success: res => {
				resolve(res.data)
			},
			fail: error => {
				reject(error)
			}
		})
	})
}

const get = (url, params = {}, code) => {
	let cinemaCode = uni.getStorageSync('cinemaCode') || BASE_CINEMA_CODE
	if (code) cinemaCode = code
	const baseUrl = `https://pandl.xyz/JavaWeb5/api`
	return new Promise((resolve, reject) => {
		uni.request({
			header: {
				cinemaCode
			},
			url: baseUrl + url,
			data: params,
			method: 'GET',
			success: res => {
				resolve(res.data)
			},
			fail: error => {
				reject(error)
			}
		})
	})
}

export {
	post,
	get,
	BASE_CINEMA_CODE
}